//
//  EnumViewController.swift
//  test_swift
//
//  Created by fangyuan ding on 2021/5/31.
//

import UIKit
enum DogName:String{
   case taidi = "taidi"
   case fadou = "fadou"
   case jinmao = "jinmao"
}

let taidi = DogName.taidi.rawValue
let fadou = DogName.fadou.rawValue
let jinmao = DogName.fadou.rawValue
class EnumViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        print("taidi=\(taidi),fadou=\(fadou),jinmao=\(jinmao)")
        enum Weight : Int {
           case light = 0
           case Mid = 1
           case Heavy = 2
       }
        let mid = Weight(rawValue: 1)
        print(mid as Any)
       
        enum Dog:CaseIterable {
          case jinmao
          case taidi
          case faniu
       }
       let numOfDogKind = Dog.allCases.count
       print("numOfDogKind = \(numOfDogKind)")
       //numOfDogKind = 3
       for dogKind in Dog.allCases{
             print(dogKind)
         }
       //jinmao
       //taidi
       //faniu
        
        enum Pet{
            //名字和年龄
            case dog(String,Int)
            //体重
            case cat(Float)
        }
          var result = Pet.dog("老七", 3)
           result = Pet.cat(2.0)
           print(result)
           switch result {
           case .dog(let name, let age):
               print("dog: name = \(name), age = \(age).")
           case .cat(let weight):
               print("cat: weight = \(weight)公斤")
           }
        
        
    }
    


}
